#include <iostream>
#include <cstring>
using namespace std;
const int N=30;

int f[N],st[N];
int din[N],dout[N];
int t,n;
int find(int x)
{
	if(x!=f[x])
		f[x]=find(f[x]);
	return f[x];
}
int main()
{
	cin>>t;
	while(t--)
	{
		cin>>n;
		memset(din,0,sizeof(din));
		memset(dout,0,sizeof(dout));
		memset(st,0,sizeof(st));
		for(int i=0;i<26;i++)
			f[i]=i;
			
		for(int i=0;i<n;i++)
		{
			string str;
			cin>>str;
			int a=str[0]-'a',b=str[str.size()-1]-'a';
			st[a]=st[b]=true;
			din[a]++,dout[b]++;
			f[find(a)]=find(b);
		}
		int start=0,en=0;
		bool flg=true;
		for(int i=0;i<26;i++)
		{
			if(din[i]!=dout[i])
			{
				if(din[i]+1==dout[i])
				{
					en++;
				}
				else if(din[i]==dout[i]+1)
				{
					start++;
				}
				else{
					flg=false;
					break;
				}
			}
		}
		if(flg && !(!start && !en || start==1 && en==1))
		{
			flg=false;	
		}
		int rep=-1;
		for(int i=0;i<26;i++)
		{
			if(st[i])
			{
				if(rep==-1)
					rep=find(i);
				else if(rep!=find(i))
				{
					flg=false;
					break;
				}
			}
		}
		if(flg)
		{
			cout<<"Ordering is possible."<<endl;
		}
		else{
			cout<<"The door cannot be opened."<<endl;
		}
		
				
	}
	return 0;
}
